package com.leo.chapter15;

import jdk.nashorn.internal.objects.annotations.Where;

/**
 *
 * @author xuexiaolei
 * @version 2017年10月20日
 */
public class CasCounter {
    private SimulatedCAS value;

    public int getValue(){
        return value.get();
    }

    public int increment(){
        int v;
        do {
            v = value.get();
        } while (!value.compareAndSet(v, v+1));
        return v+1;
    }
}
